package collector.task;

import java.util.Date;

import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.SimpleTrigger;

import net.apexcns.core.BaseVO;

/**
 * <pre>
 * Class : collector.task.JobTaskVO / JobTaskVO.java
 * 	Define Class Object : jobIDs, jobKey, scheduleTime이 정의된 Task 스케줄 객체
 *  Quartz의 작업 및 트리거에 대한 Task 객체
 *  작업명, 작업그룹으로 구성된 작업 객체와 
 *  트리거명, 트리거그룹, 스케줄 시작시각, 주기 분류, 
 *  주기로 구성된 Trigger 에 대한 객체를 포함한다.
 * <br>
 * </pre>
 * 
 * @author ytjeong / apexcns,Inc.
 * @version 1.0
 * @see javadoc
 * @since 2012. 9. 12.
 */
@SuppressWarnings("serial")
public class JobTaskVO extends BaseVO {

	protected String jobIDs = null;
	protected Date scheduleTime = null; // 현재 스케줄 시간
	protected Date registScheduleTime = null; // 초기 스케줄 등록 시간
	protected JobKey jobKey = null;
	protected JobDetail job = null;
	protected SimpleTrigger trigger = null;

	/**
	 * <pre>
	 * Method : JobTaskVO.getJobIDs()
	 * 	to get jobIDs
	 * <br> 
	 * @return the jobIDs : type of String
	 * </pre>
	 */
	public String getJobIDs() {
		return jobIDs;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.setJobIDs()
	 * 	to set jobIDs 
	 * <br> 
	 * @param jobIDs : type of String
	 * </pre>
	 */
	public void setJobIDs(String jobIDs) {
		this.jobIDs = jobIDs;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.getJobKey
	 * 	to get jobKey
	 * <br> 
	 * @return the jobKey : type of JobKey
	 * </pre>
	 */
	public JobKey getJobKey() {
		return jobKey;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.setJobKey
	 * 	to set jobKey 
	 * <br> 
	 * @param jobKey : type of JobKey
	 * </pre>
	 */
	public void setJobKey(JobKey jobKey) {
		this.jobKey = jobKey;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.getJob
	 * 	to get job
	 * <br> 
	 * @return the job : type of JobDetail
	 * </pre>
	 */
	public JobDetail getJob() {
		return job;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.setJob
	 * 	to set job 
	 * <br> 
	 * @param job : type of JobDetail
	 * </pre>
	 */
	public void setJob(JobDetail job) {
		this.job = job;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.getTrigger
	 * 	to get trigger
	 * <br> 
	 * @return the trigger : type of SimpleTrigger
	 * </pre>
	 */
	public SimpleTrigger getTrigger() {
		return trigger;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.getScheduleTime()
	 * 	to get scheduleTime
	 * <br> 
	 * @return the scheduleTime : type of Date
	 * </pre>
	 */
	public Date getScheduleTime() {
		return scheduleTime;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.setScheduleTime()
	 * 		to set scheduleTime 
	 * <br> 
	 * @param scheduleTime : type of Date
	 * </pre>
	 */
	public void setScheduleTime(Date scheduleTime) {
		this.scheduleTime = scheduleTime;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.setTrigger
	 * 	to set trigger 
	 * <br> 
	 * @param trigger : type of SimpleTrigger
	 * </pre>
	 */
	public void setTrigger(SimpleTrigger trigger) {
		this.trigger = trigger;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.viewSchedule()
	 * 		스케줄링 정보 출력
	 * 		Ex) [Group.Name] will run at: Sat Sep 15 03:00:40 KST 2012 and repeat: -1 times, every 60 seconds
	 * <br>
	 * 	return type of String
	 * <br>
	 * @return
	 * </pre>
	 */
	public String toStringInfoSchedule() {
		return getJobKey().toString() + " regist at: "
				+ getRegistScheduleTime() + " will run at: "
				+ getScheduleTime() + " and repeat: "
				+ getTrigger().getRepeatCount() + " times, every "
				+ getTrigger().getRepeatInterval() / 1000 + " seconds";
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.getRegistScheduleTime()
	 * 	to get registScheduleTime
	 * <br> 
	 * @return the registScheduleTime : type of Date
	 * </pre>
	 */
	public Date getRegistScheduleTime() {
		return registScheduleTime;
	}

	/**
	 * <pre>
	 * Method : JobTaskVO.setRegistScheduleTime()
	 * 	to set registScheduleTime 
	 * <br> 
	 * @param registScheduleTime : type of Date
	 * </pre>
	 */
	public void setRegistScheduleTime(Date registScheduleTime) {
		this.registScheduleTime = registScheduleTime;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 * 
	 * Method : collector.task.JobTaskVO.toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("JobTaskVO [jobIDs=").append(jobIDs)
				.append(", registScheduleTime=").append(registScheduleTime)
				.append(", scheduleTime=").append(scheduleTime)
				.append("\n\t\t").append(", jobKey=").append(jobKey)
				.append(", job=").append(job).append(", trigger=")
				.append(trigger).append("]").append("\n\t");
		return builder.toString();
	}

}
